<?php 



$newReg = true;

if($_GET['id_usuario']){

	

	require_once('basico/start.php');

	$conn = $GLOBALS['connectionDefault'];

	$logger = Logger::getInstance();

	

	if($_GET['id_usuario'] != $_SESSION['id_usuario']){

		$resposta = new Resposta();

		$resposta->redirect(false);

	}

	

	$query = "SELECT c.id_cliente,

					 c.sexo,

					 c.data_nascimento,

					 u.nome,

					 u.email,

					 u.senha

			  FROM cliente AS c

			  INNER JOIN usuario AS u

			  		  ON u.id_cliente = c.id_cliente 

			  WHERE u.id_usuario = %0d";

	$query = sprintf($query, $_GET['id_usuario']);

	if(!$conn->query($query))$logger->gravaLogErro('Erro ao buscar cliente', $conn->error, null, $query);

	$rec = $conn->next();

	

	$id = $rec['id_cliente'];

	$newReg = false; 

}else{

	

	require_once('basico/start_no_auth.php');

	

	$conn = $GLOBALS['connectionDefault'];

	$logger = Logger::getInstance();

}



require_once ('basico/class/Formatacao.php');

require_once('desconto2d/class/Layout.php');



?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="http://www.2ddesconto.com.br/desconto2d/style/style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="http://www.2ddesconto.com.br/desconto2d/Scripts/restrict.js"></script>

<script type="text/javascript" src="http://www.2ddesconto.com.br/desconto2d/Scripts/validacao.js"></script>

<script type="text/javascript" src="http://www.2ddesconto.com.br/desconto2d/Scripts/usuario.js"></script>

<title>2D Desconto</title>


<script src="../Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="../Scripts/functions.js" type="text/javascript"></script>

</head>

<body>

<?php 

echo Layout::getTopo();
echo Layout::getMenu();

 ?>

<div id="site" class="novo-site">

	<div id="principal">





<!-- ///////////////////////////////////////////////////////////////////////////// -->



<div id="fields2">



<form id="formCliente" action="http://www.2ddesconto.com.br/desconto2d/forms/cliente_p.php" method="post">



<?php 

		echo sprintf('<input type="hidden" name="id_cliente" id="id_cliente" value="%s">', $id);

?>

<table align="center">



<tr><th colspan="2"><h1 class="tit-autenticacao">Cliente</h1></th></tr>

<tr>

	<td style="text-align:right;"><strong>Nome*:</strong></td>

	<td>

	<?php 

		echo sprintf('<input type="text" name="nome" id="nome" size="50" value="%s" />', $rec['nome']);

	?>

	</td>

</tr><tr>

	<td style="text-align:right;"><strong>E-mail*:</strong></td>

	<td>

	<?php 

		echo sprintf('<input type="text" name="email" id="email" size="50" value="%s" />', $rec['email']);

	?>

	</td>

</tr><tr>

	<td style="text-align:right;"><strong>Sexo*:</strong></td>

	<td>

	<select id="sexo" name="sexo">

	

	<?php

	

	echo sprintf('<option %s value="" >Selecione</option>', !$rec['sexo']?"Selected":"");

	echo sprintf('<option %s value="M">Masculino</option>', $rec['sexo']=="M"?"Selected":"");

	echo sprintf('<option %s value="F">Feminino</option>', $rec['sexo']=="F"?"Selected":"");

	

	?>

	</select>

	</td>

</tr><tr>

	<td style="text-align:right;"><strong>Data de Nascimento*:</strong></td>

	<td>

	<?php 

		if($rec['data_nascimento'])$data = Formatacao::converteDataSqlBrasil($rec['data_nascimento']);

		echo sprintf('<input type="text" onBlur="javascript:validaData(this)" name="data_nascimento" id="data_nascimento" size="12" value="%s" />', $data);

	?>

	</td>

</tr>

<?php 



//if($newReg){

	

	echo '<tr><td style="text-align:right;"><strong>Senha*:</strong></td><td>';

	echo sprintf('<input type="password" name="senha" id="senha" size="20" value="%s" />', $rec['senha']);

	echo '</td></tr>';

	echo '<tr><td style="text-align:right;"><strong>Confirma&ccedil;&atilde;o de Senha*:</strong></td><td>';

	echo sprintf('<input type="password" name="senha_confirmacao" id="senha_confirmacao" size="20" value="%s" />', $rec['senha']);

	echo '</td></tr>';

//}



//echo sprintf('<input type="hidden" name="verificaSenha" id="verificaSenha" value="%s" />', $newReg?'true':'false');

echo '<input type="hidden" name="verificaSenha" id="verificaSenha" value="true" />';



?>

<tr>

	<td></td>

	<td><input type="button" name="btn_enviar" id="btn_enviar" class="btn" value="Enviar" onClick="javascript:verificaCamposObrigatorios()"/></td>

</tr>

</table>

</form>

<script type="text/javascript">

//<![CDATA[



	var r = new Restrict("formCliente");

	

	r.field.data_nascimento = "\\d/";

	r.mask.data_nascimento = "##/##/####";

	

	r.onKeyRefuse = function(o, k){

		o.style.backgroundColor = "#fdc";

	}

	

	r.onKeyAccept = function(o, k){

		if(k > 30)

			o.style.backgroundColor = "transparent";

	}

	

	r.start();



//]]>

</script>

</div><!-- FIELDS -->





<!-- ///////////////////////////////////////////////////////////////////////////// -->





	</div><!-- PRINCIPAL -->

</div><!-- SITE -->

<?php 
	echo Layout::getBase();
?>

</body>

</html>